

<template>
  <div name="医生签名box" class="bold color-0 sign3-html">
    <span>{{ info.label }}</span>
    <div class="sing-box hw200 pointer relative" @click="BeginSign()">
      <img v-show="!!info.field_value" :src="url" class="sign-img" />
    </div>
  </div>
</template>

<script>
import { timeFormatter } from "UTILS/format";
import { simDeepCopy, getStorage, setStorage } from "UTILS/util";
import { CONSENT_GET_DOCTOR_DZQM } from "_SERVICES/api";



export default {
  name: "Sign3",
  props: {
    info: {
    },
    TPL_FORMAT: {

    },
    pdf: {

    }
  },
  data() {
    return {
      url: "",
      qm_url: "http://10.1.6.81/dzqm/dzqm.aspx?as_yhid="
    };
  },
  created() {

  },
  watch: {
    info: {
      handler(val) {
        if (!val.field_value) {
          this.url = "";
        } else {
          this.check_url()
          this.url = this.qm_url + this.info.field_value;
        }
      },
      deep: true, // 使用 deep 选项进行深度监视
      immediate: true,
    },
  },
  destroyed() { },
  methods: {
    check_url() {
      if (window.location.href.indexOf("https") > -1) {
        this.qm_url = "https://dzqm360.sysush.com/dzqm/dzqm.aspx?as_yhid="
      } else {
        this.qm_url = "http://10.1.6.81/dzqm/dzqm.aspx?as_yhid="
      }
    },
    BeginSign() {
      if(this.pdf==1){
        return false;
      }
      let userInfo = getStorage("cst_userInfo") ? JSON.parse(getStorage("cst_userInfo")) : {}
      this.info.field_value = userInfo.YHID;
      this.check_url();
      this.url = this.qm_url + this.info.field_value;
      if(this.info.field_related) {
        this.set_related_time();
      }
    },
    set_related_time() {
      if (this.TPL_FORMAT) {
        this.TPL_FORMAT.forEach((item) => {
          if (item.field_name == this.info.field_related) {
            item.field_value = timeFormatter(new Date(), 4)
          }
        })
      }
    }
  },
};
</script>

<style  lang="less">
.sign3-html {
  margin-top: 20px;

  .sing-box {
    display: inline-block;
    height: 22px;

  }

  .sign-img {
    position: absolute;
    left: 20px;
    // width: 100px;
    height: 40px;
    bottom: -10px;
    z-index: 1;
  }

}
</style>

